<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'list.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/content.css">
	<style type="text/css">
		#down table {
			position: relative;
			left: 50%;
			margin-left: -390px;
			top: 50px;
			border-top: 1px #999 solid;
			border-right: 1px #999 solid;
		}
		#down tr {
			height: 60px;
		}
		
		#down tr td {
			text-align: center;
			border-left: 1px #999 solid;
			border-bottom: 1px #999 solid;
		}
		
		#up a:VISITED,#up a:LINK {
			color: #4C8FBD;
			text-decoration: none;
		}
		#up a:HOVER {
			color: #4C8FBD;
			text-decoration: none;
		}
		.head {
			background: #438EB9;
			color: #fff;
		}
		tbody tr:nth-child(odd) {
			background: #e5e5e5;
		}
		
		tbody tr:nth-child(even) {
			background: #d5d5d5;
		}
	</style>
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
	$(function() {
		$(".updt").click(function() {
				var href = $(this).attr("href");
				alert(href);
				$("form").attr("action", href).submit();
				return false;
		});
	});
</script>
  </head>
  
  <body>
  <form action="order/adminsearch_order" method="get">
 <!--  <input type="hidden" name="_method" value="GET"> 不显示  -->
  	<div id="up">
	   <ul>
	    	<li>
	    	<span>
	    	 <a href="admin/welcome">平台首页 </a>&nbsp;&nbsp;&nbsp;&nbsp;
	    	 <a href="order/admin_order/2" class="nav-link" target="con">未发货订单</a>&nbsp;&nbsp;
	    	 <a href="order/admin_order/3" class="nav-link" target="con">已发货订单</a>&nbsp;&nbsp;
	    	 <a href="order/admin_order/4" class="nav-link" target="con">退款中</a>&nbsp;&nbsp;
	    	 <a href="order/admin_order/5" class="nav-link" target="con">退款完成订单</a>&nbsp;&nbsp;
	    	 <a href="order/admin_order/6" class="nav-link" target="con">交易成功订单</a>&nbsp;&nbsp;
	    	 <!-- <a href="order/admin_mouthorder" class="nav-link" target="con">订单统计</a>&nbsp;&nbsp;
	    	 -->
		    <right>
		     <input type="text" name="str" id="in" autocomplete="off">
		     <input type="submit" value="搜&nbsp;索" id="su">
		   </right>
		   </span>
	    	</li>
	   </ul>
	</div>
	</form>
	<div id="down">
	<c:if test="${empty orders }">
								<span style="color: #f00" ><center>该界面下暂无订单</center></span>
	</c:if>
	<c:if test="${not empty orders }">
	    <table width="800px" cellpadding="0" cellspacing="0" >
	    	<thead>
		    	<tr class="head">
		    		<td>序号</td>
		    		<td>用户昵称</td>
		    		<td>订单商品</td>
		    		<td>商品数量</td>
		    		<td>订单总价</td>
		    		<td>订单收货地址</td>
		    		<td>订单状态</td>
		    		<td>操作</td>
		    	</tr>
	    	</thead>
	    	
	    	<tbody>
	 
				<c:forEach items="${orders }" var="orders" varStatus="i">
				
				<tr style="height: 10px">
				<th colspan="3" align="left">${orders.date }</th>
				<th colspan="5" align="center">用户名：${orders.user.username }</th> 
    			</tr>   
			    	<tr>
			    	 
			    		<td>${i.index + 1 }</td>
			    		<td>${orders.user.nickname }</td>
						<td>
						    <c:forEach items="${orders.orderProducts }" var="orderProduct">

								<ul>
								   <%-- 订单商品图片
								    <li><img src="<%=request.getContextPath()%>/image/${orderProduct.product.imgs[0].name}" height="80px"></li>
								     --%>
									<li>${orderProduct.product.name }</li>

								</ul>
							</c:forEach>
						</td>
						<td>
			    		    <c:forEach items="${orders.orderProducts }" var="orderProduct1" >
			    		          <ul>
			    		               <li>${orderProduct1.quantity }</li>
			    		          </ul>
			    		    </c:forEach>
			    		</td>
			    		
			    		
			    		
			    		<td>${orders.price }</td>
			    		<td>
			    		  ${orders.address.base}
			    		  ${orders.address.place}
			    	    </td>
			    		
			    		<td>
			    		
											<c:if test="${orders.status eq 1 }">
												<span style="color: #f00">未付款</span>
											</c:if>
											
											<c:if test="${orders.status eq 2 }">
												<span>等待发货</span>
											</c:if>
											<c:if test="${orders.status eq 3 }">
												<span>卖家已发货</span>
											</c:if>
											<c:if test="${orders.status eq 4 }">
												<span>订单退款中</span>
											</c:if>
											<c:if test="${orders.status eq 5 }">
												<span>订单退款完成</span>
											</c:if>
											<c:if test="${orders.status eq 6 }">
												<span>订单交易成功</span>
											</c:if>
											
    					
			    		</td>
			 
			    		
			    		<td>
			    		                       <c:if test="${orders.status eq 2 }">
			    		                       
    												<a href="order/adupdate_order/${orders.id }/3" class="updt">确认发货</a><br>
    												
    											</c:if>
    											<c:if test="${orders.status eq 3 }">
    												<span>已发货</span>
    												
    											</c:if>
    											<c:if test="${orders.status eq 4 }">
    												<a href="order/adupdate_order/${orders.id }/5" class="updt">确认退款</a><br>
    												
    											</c:if>
    											<c:if test="${orders.status eq 5 }">
    												<span>订单退款成功</span>
    												
    											</c:if>
    											<c:if test="${orders.status eq 6 }">
    												<span>已完成订单</span>
    												
    											</c:if>
			    			
			    		</td>
		           </tr>
				</c:forEach>
				
			</tbody>
	    </table>
	  </c:if>
	 
    </div>
               <!-- 用javascript将update的提交方式由get改为post -->
	<form action="" method="post">
		<input type="hidden" name="_method" value="PUT"> <!--不显示  -->
	</form>
  </body>
</html>
